package cn.fzkj.springcloud.controller;

import cn.fzkj.springcloud.entity.CommonResult;
import cn.fzkj.springcloud.entity.Payment;
import cn.fzkj.springcloud.service.PaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/payment")
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private Integer port;

    /**
     * 按id查询
     * @param id
     * @return
     */
    @GetMapping(value = "getPaymentById/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
        System.out.println("本次是： " + port + " 提供服务");
        return new CommonResult<Payment>(paymentService.getPaymentById(id));
    }

    /**
     * 插入
     * @param payment
     * @return
     */
    @PostMapping(value = "create")
    public CommonResult create(@RequestBody Payment payment){
        return new CommonResult(paymentService.create(payment));
    }


}
